package com.haoze.nurseapp.controller;

import com.haoze.common.response.Result;
import com.haoze.nurseapp.dto.BedDTO;
import com.haoze.nurseapp.service.BedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@Api(value = "床位设置")
@RequestMapping("/nurseapp/bed")
public class BedController {
    @Autowired
    private BedService bedService;

    /**
     * 床位状态查询你好
     * @param page
     * @param pageSize
     * @param wardId
     * @return
     */
    @GetMapping("/queryBedNoStatus")
    @ApiOperation(value = "床位状态查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页数", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页长", required = true),
            @ApiImplicitParam(name = "wardId", value = "病区", required = true),
            @ApiImplicitParam(name = "status", value = "-1 全部  1:在用 0：空床", required = true),
    })
    public Result queryBedNoStatus(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "20") int pageSize,
                        @RequestParam String wardId,@RequestParam(required = false) String status) {
        return bedService.queryBedNoStatus(wardId,status,page,pageSize);

    }

    /**
     * 获取下拉框信息
     * @param varCode
     * @return
     */
    @GetMapping("/queryDropDownList")
    @ApiOperation(value="获取下拉框信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "varCode", value = " bed_sex-床位男女 bed_category-床位类别 bed_grade-床位等级 bed_status-是否空床", dataType = "String", paramType = "dataVersionId")
    })
    public Result queryDropDownList(@RequestParam(required = false) String varCode,
                                    @RequestParam(required = false) String keyWords,
                                    @RequestParam(defaultValue = "1")  Integer page,
                                    @RequestParam(defaultValue = "20")  Integer pageSize,
                                    @RequestParam(required = false) String id){
        return bedService.queryDropDownList(varCode,keyWords,page,pageSize,id);
    }

    /**
     * 床位列表
     * @param page
     * @param pageSize
     * @param wardId
     * @return
     */
    @GetMapping("/queryBedNoList")
    @ApiOperation(value = "床位列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页数", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页长", required = true),
            @ApiImplicitParam(name = "wardId", value = "病区", required = true),
            @ApiImplicitParam(name = "keyWords", value = "", required = true),
    })
    public Result queryBedNoList(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "20") int pageSize,
                                   @RequestParam String wardId,@RequestParam(required = false) String keyWords) {
        return bedService.queryBedNoList(wardId,keyWords,page,pageSize);
    }

    /**
     * 获取顺延床号
     * @param wardId
     * @return
     */
    @GetMapping("/queryPostponeBedNo")
    @ApiOperation(value = "获取顺延床号")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "wardId", value = "病区", required = true)
    })
    public Result queryPostponeBedNo(@RequestParam String wardId) {
        return bedService.queryPostponeBedNo(wardId);
    }


    @PostMapping("/saveBed")
    @ApiOperation(value = "保存")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "wardId", value = "病区", required = true)
    })
    public Result saveBed(@RequestBody BedDTO bedDTO) {
        return bedService.saveBed(bedDTO);
    }

    @GetMapping("/{bedId}")
    @ApiOperation(value = "修改获取数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "bedId", value = "床Id", required = true)
    })
    public Result queryByBedId(@PathVariable String bedId) {
        return bedService.queryByBedId(bedId);
    }

    @DeleteMapping("/{bedId}")
    @ApiOperation(value = "删除床号")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "bedId", value = "床Id", required = true)
    })
    public Result deleteByBedId(@PathVariable String bedId) {
        return bedService.deleteByBedId(bedId);
    }
}
